import { Component, _decorator } from "cc";
const { ccclass, property } = _decorator;

@ccclass('BranchAdapter')
export class BranchAdapter extends Component {
    private _dirty: boolean = false;
    public avalible: boolean = false;
    public applyBranchCallback: ()=>void;

    protected onEnable(): void {
        if (!this.avalible || !this._dirty) return;
        this._dirty = false;
        this.updateBranch();
    }

    protected onDisable(): void {
        this._dirty = true;
    }

    updateBranch(): void {
        this.applyBranchCallback && this.applyBranchCallback();
    }
}